<?php
require_once __DIR__.'/../../lib/PAutoLoader.php';

$config = array(
//     'services' => array(
//         'LoginService' => 'com\penngo\LoginServiceClient',
//         'RegisterService' => 'com\penngo\RegisterServiceClient'
//     ),
    'gen-php' => dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'gen-php',
    'address' => array(
        '127.0.0.1:8080'
    ),
    'registry' => array( // 注册中心服务器
        '127.0.0.1:8081',
        '127.0.0.1:8082'
    )
);



use Thrift\Exception\TException;
use Swoole\Thrift\ThriftHttpClient;
use com\penngo\LoginServiceClient;
try {

    ThriftHttpClient::init($config);
    $loginServiceClient = ThriftHttpClient::getService('LoginService');
    //$loginServiceClient = new LoginServiceClient($thriftServiceProtocol);
    $rec = $loginServiceClient->login("penngo", "123");
    print_r($rec);
    
    $registerServiceClient = ThriftHttpClient::getService('RegisterService');
    $rec = $registerServiceClient->createUser("penngo", "123");
    print_r($rec);
    
} catch (TException $tx) {
    print 'TException: '.$tx->getMessage()."\n";
}

?>